import { request } from '@/utils';
import { getRestBaseUrl } from '@/config';
import { LOAD_LIST_REQUEST_TASK_NAME, LOAD_EXECUTE_RECORD_LIST_REQUEST_TASK_NAME } from './constants';

// 查询分时段任务列表
export const loadAdjustPriceListApi = (taskForm, page) =>
  request({
    url: `${getRestBaseUrl()}/iop/timeTaskService/list`,
    method: 'POST',
    data: { taskForm, page },
    requestTaskName: LOAD_LIST_REQUEST_TASK_NAME,
    timeout: 3 * 60 * 1000,
  });

export const loadTaskExecuteRecordApi = data =>
  request({
    url: `${getRestBaseUrl()}/iop/timeTaskService/listExecuteTask`,
    method: 'POST',
    data,
    requestTaskName: LOAD_EXECUTE_RECORD_LIST_REQUEST_TASK_NAME,
    timeout: 3 * 60 * 1000,
  });

export const canTaskApi = masterTaskId =>
  request({
    url: `${getRestBaseUrl()}/iop/timeTaskService/cancel`,
    method: 'POST',
    data: { masterTaskId },
    timeout: 3 * 60 * 1000,
  });
